// MyFrame.cpp : implementation file
//

#include "stdafx.h"
#include "a1.h"
#include "MyFrame.h"
#include "ScrollPrintView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyFrame

IMPLEMENT_DYNCREATE(CMyFrame, CFrameWnd)
static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};
CMyFrame::CMyFrame()
{
}

CMyFrame::~CMyFrame()
{
}
BEGIN_MESSAGE_MAP(CMyFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMyFrame)
	ON_WM_CREATE()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyFrame message handlers





int CMyFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
//		m_wndSplitter.CreateStatic(this, 1, 2, WS_CHILD | WS_VISIBLE);
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	
	this->SetIcon(LoadIcon(::AfxGetResourceHandle(),MAKEINTRESOURCE(IDI_ICON_PRINT)),false);

	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);


	return 0;
}

void CMyFrame::OnDestroy() 
{
		TRACE("BE	CFrameWnd::OnDestroy()\n");
	CFrameWnd::OnDestroy();
		TRACE("AF	CFrameWnd::OnDestroy()\n");
}

BOOL CMyFrame::DestroyWindow() 
{
		TRACE("BE CFrameWnd::DestroyWindow()\n");
		BOOL	RESULT=CFrameWnd::DestroyWindow();
		TRACE("AF CFrameWnd::DestroyWindow()\n");

	return RESULT;


}

BOOL CMyFrame::PreTranslateMessage(MSG* pMsg) 
{
	if(pMsg->message==WM_KEYDOWN&&pMsg->wParam==13)
	{
		int iID=::GetDlgCtrlID(pMsg->hwnd);
		switch(iID)
		{
		case IDC_EDIT_ROWS:
			this->SendMessage(WM_COMMAND,IDC_BUTTON_ROWCOLUMN,0);
			break;
		case IDC_EDIT_COLUMNS:
			this->SendMessage(WM_COMMAND,IDC_BUTTON_ROWCOLUMN,0);
			break;
		case IDC_EDIT_SCALE:
			this->SendMessage(WM_COMMAND,IDC_GETSCALE,0);
			break;
		}
	}
	else if(pMsg->message==WM_CHAR)
	{
		int iID=::GetDlgCtrlID(pMsg->hwnd);
		switch(iID)
		{
		case IDC_EDIT_ROWS:
		case IDC_EDIT_COLUMNS:
		case IDC_EDIT_SCALE:

		if(!((pMsg->wParam>=0x30&&pMsg->wParam<=0x39)||pMsg->wParam==0x08))
		{
			pMsg->wParam=VK_CONTROL;
			break;
		}
		default:
			break;
		}
	}
	return CFrameWnd::PreTranslateMessage(pMsg);
}

BOOL CMyFrame::PreCreateWindow(CREATESTRUCT& cs) 
{
	// TODO: Add your specialized code here and/or call the base class
	
	return CFrameWnd::PreCreateWindow(cs);
}


